<template>
  <div>
    <span>姓名：</span>
    <input type="text" v-model="name" /> <br /><br />
    <span>年龄：</span>
    <input type="text" v-model="age" /><br /><br />
    <span>身高：</span>
    <input type="text" v-model="height" />(米) <br /><br />
    <span>体重：</span>
    <input type="text" v-model="weight" />(公斤) <br /><br />
    <span>病史：</span>
    <input type="text" v-model="cas" /><br /><br />
    <button @click="add">诊断</button><br /><br />
    <span ref="del"></span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: '',
      age: '',
      height: '',
      weight: '',
      cas: '',
      BIM: '',
      tex: ''
    }
  },
  methods: {
    add() {
      this.BIM = this.weight / (this.height * this.height)
      if (this.BIM <= 18.5) {
        this.tex = '体重过轻'
      } else if (this.BIM <= 24.9) {
        this.tex = '正常'
      } else if (this.BIM > 29.0) {
        this.tex = '体重过重'
      }
      console.log(this.tex)
      this.$refs.del.innerHTML = '患者:' + this.name + '诊断结果:' + this.tex
    }
  }
}
</script>

<style></style>
